
<h2> View All Words </h2>

<div style="position: relative; margin-top: -43px;">

    <table class="table table-striped table-bordered table-condensed" id="words" style="margin-bottom: 0;">
        <thead>
            <tr>
                <th>Key</th>
                <th>Word</th>
                <th class="th-action center">Action</th>
            </tr>
        </thead>
        <tbody>

            <?  
                $k=0;
                foreach($all_words as $word): ?> 

                <tr <?if($k%2==0)echo 'class="tr-odd"';?>>

                    <td><a href="<?=base_url()?><?=$link?>/view_edit_word?post_type=words&post_ID=<?=$word['ID']?>"><strong><?=clean_html($word['key'])?></strong></a></td>
                    <td><?=clean_html($word['word'])?></td>
                    <td class="center last">
                        <a href="<?=base_url()?><?=$link?>/view_edit_word?post_type=words&post_ID=<?=$word['ID']?>">Edit</a> |
                        <a href="<?=base_url()?><?=$link?>/delete_word/<?=$word['ID']?>" class="delete_post">Delete</a>
                    </td> 

                </tr>                                      

                <? 
                    $k++;
                    endforeach; ?>

        </tbody>
    </table>

    <div class="spacer"></div>
    <div id="publishing-action">
        <div>
            <a href="<?=base_url()?><?=$link?>/view_new_word?post_type=words" title="Add Word" class="btn">Add Word</a>
        </div>
    </div>

    <div class="spacer"></div>

</div>
<!--</div>--> 
<script type="text/javascript" charset="utf-8">
    jQuery(document).ready(function() {

            oTable = jQuery('#words').dataTable({
                    "aaSorting": [[ 0, "asc" ]],    
                    "bJQueryUI": true,
                    "sPaginationType": "full_numbers" ,
                    "bPaginate": false
            }); 

            jQuery('.delete_post').live('click',function(){

                    var conf = confirm("Delete word?")
                    if (!conf){
                        return false;
                    }

                    window.location.href = jQuery(this).attr('href');

                    return false;

            });


    } );
</script>
